/*
package org.jeecg.jt808.task;

import org.eclipse.paho.client.mqttv3.MqttException;


import org.jeecg.jt808.JTT808Decoder;
import org.jeecg.jt808.JTT808Encoder;
import org.jeecg.jt808.JTT808Message;
import org.jeecg.jt808.task.log.LogType;
import org.jeecg.jt808.vo.JT808DataPacket;
import org.jeecg.jt808.vo.Packet;
import org.jeecg.mqtt.model.Point;
import org.jeecg.mqtt.model.UniqueSerialNumberGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;

*/
/**
 * Created by matrixy when 2020/5/9.
 *//*

public class SimpleDriveTask extends AbstractDriveTask
{
    static Logger logger = LoggerFactory.getLogger(SimpleDriveTask.class);


    private long id;

    // 部标808协议连接id
    String connectionId;

    // 1078多媒体传输协议接连id
    String multimediaConnectionId;

    // 消息包流水号
    int sequence = 1;

    // 最后发送的消息ID
    int lastSentMessageId = 0;

    // 以米为单位的总行程里程数
    int mileages = 0;
    Point lastPosition = null;


    SimpleDateFormat sdf = new SimpleDateFormat("YYMMddHHmmss");

    final JTT808Message GENERAL_RESPONSE = new JTT808Message(0x0001);




    @Override
    public String generateVehicleControlMessage(JTT808Message msg){
        byte controlCommand = (byte) 0x94; // 车辆控制指令，例如熄火指令
        byte controlParameter = 0x00; // 车辆控制参数，例如熄火参数

        msg.sequence = 0x00; // 设置消息序列号，用于消息的顺序管理
        msg.packetCount = 0; // 设置分包总数，如果消息体超过1024字节需要分包发送
        msg.packetIndex = 0; // 设置分包索引，表示当前分包的序号

        //byte reminP=0x00;
         msg.id=0x8500;
         Packet p = Packet.create(2);
         p.addByte(controlCommand);
         p.addByte(controlParameter);
         //p.addByte(reminP);
         //p.addByte(reminP);
         msg.body = p.getBytes();
         return bytesToHexString(send(msg));

    }


    @Override
    public byte[] send(JTT808Message msg) {
        //msg.sim = getParameter("device.sim");
        //msg.sequence = (short)((sequence++) & 0xffff);
        lastSentMessageId = msg.id;
        logger.info("send: {} -> {} : {}", msg.sim, msg.sequence, String.format("%04x", msg.id));
        return  JTT808Encoder.encode(msg);
    }

    private void log(LogType logType, String string) {
    }


    @Override
    public void startup() {

    }

    @Override
    public void terminate() {

    }


    public static void main(String[] args) throws MqttException {
        SimpleDriveTask simpleDriveTask=new SimpleDriveTask();
        JTT808Message message=new JTT808Message();
        String sim="18251893735";
        String vi="xxx111";
        message.setSim(sim);
        UniqueSerialNumberGenerator.generateSerialNumber(vi);

        //String sss= simpleDriveTask.generateVehicleControlMessage(message);

        JT808DataPacket dataPacket= JTT808Decoder.decode("7E0200004C947067763112000600000080000C0010015B198D06C8360D0009000000002406041840350104000000B402020000030200002504000000002A0200002B0400000000300114310118E30600000B14017D01F2020000967E");



    }

    public static String bytesToHexString(byte[] bytes) {
        StringBuilder hexString = new StringBuilder();
        for (byte b : bytes) {
            String hex = Integer.toHexString(b & 0xFF);
            if (hex.length() == 1) {
                hexString.append('0');
            }
            hexString.append(hex);
        }
        return hexString.toString().toUpperCase();
    }

}*/
